package com.ruoyi.tzzl.service.imp;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.tzzl.domain.WzUserDetails;
import com.ruoyi.tzzl.mapper.WzUserDetailsMapper;
import com.ruoyi.tzzl.service.IWzUserDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 用户详情Service业务层处理
 * @author by caoyong
 * @date 2022/11/8
 **/
@Service
public class WzUserDetailsServiceImpl extends ServiceImpl<WzUserDetailsMapper, WzUserDetails> implements IWzUserDetailsService {

    @Autowired
    private WzUserDetailsMapper wzUserDetailsMapper;


    /**
     * 查询用户详情
     *
     * @param id 用户详情主键
     * @return 用户详情
     */
    @Override
    public WzUserDetails selectWzUserDetailsById(Long id) {
        LambdaQueryWrapper<WzUserDetails> lqw =new LambdaQueryWrapper<>();
        lqw.eq(WzUserDetails::getWid,id);
        return this.getOne(lqw);
    }

    /**
     * 删除详情
     *
     * @param ids
     */
    @Override
    public boolean deleteDetails(List<String> ids) {
        LambdaQueryWrapper<WzUserDetails> lqw =new LambdaQueryWrapper<>();
        lqw.in(WzUserDetails::getWid,ids);
        List<WzUserDetails> list = this.list(lqw);
        List<Long> dis =new ArrayList<>();
        if (ObjectUtils.isNotEmpty(list)){
            for (int i = 0; i < list.size(); i++) {
                dis.add(list.get(i).getId());
            }
           return this.removeByIds(dis);
        }
        return  true;
    }
}
